package com.example.demo.controller;

import com.example.demo.domain.Reserve;
import com.example.demo.domain.Result;
import com.example.demo.service.ReserveService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/reserve")
@RestController
public class ReserveController {

    @Autowired
    ReserveService reserveservice;

    //查询所有
    @RequestMapping("/findAllReserve")
    public Result findAllReserve(){
        List<Reserve> list = reserveservice.findAllReserve();
        return Result.ok(list);
    }

    //删除预定订单信息
    @RequestMapping("/deleteReserve")
    public Result deleteReserve(Integer id){
        reserveservice.deleteReserve(id);
        return Result.ok();
    }

    //添加预定订单信息
    @RequestMapping("/addReserve")
    public Result addReserve(@RequestBody @Param("data") Reserve data){
        System.out.println(data);
        reserveservice.addReserve(data);
        return Result.ok();
    }

    //修改预定订单信息
    @RequestMapping("/updateReserve")
    public Result updateReserve(@RequestBody @Param("data")  Reserve data){
        System.out.println(data);
        reserveservice.updateReserve(data);
        return Result.ok();
    }

    //查询预定订单信息
    @RequestMapping("/findReserve")
    public Result findReserve(@RequestBody @Param("data") Reserve data){
        System.out.println(data);
        List<Reserve> list = reserveservice.findReserve(data);
        return Result.ok(list);
    }
}
